package com.j48.entrancegurad.controller;

import com.j48.entrancegurad.config.LoginFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootConfiguration
public class MySpringFilter extends WebMvcConfigurerAdapter {
    @Autowired
    private LoginFilter loginFilter;

    /**
     * 自定义拦截器
     * @param registry 继承WebMvcConfigurerAdapter类，重写addInterceptors方法
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器，添加拦截路径和排除拦截路径
        registry.addInterceptor(loginFilter).addPathPatterns("/home").excludePathPatterns("/login");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectAdmin");
        registry.addInterceptor(loginFilter).addPathPatterns("/adminAddController");
        registry.addInterceptor(loginFilter).addPathPatterns("/deleteOrUpdateAdminController");
        registry.addInterceptor(loginFilter).addPathPatterns("/updateAdminController");
        registry.addInterceptor(loginFilter).addPathPatterns("/findadminname");
        registry.addInterceptor(loginFilter).addPathPatterns("/modifyrole");
        registry.addInterceptor(loginFilter).addPathPatterns("/flush");
        registry.addInterceptor(loginFilter).addPathPatterns("/flush1");
        registry.addInterceptor(loginFilter).addPathPatterns("/flush2");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectcharacter");
        registry.addInterceptor(loginFilter).addPathPatterns("/addcharacter");
        registry.addInterceptor(loginFilter).addPathPatterns("/modifycharacter");
        registry.addInterceptor(loginFilter).addPathPatterns("/jugerepeat");
        registry.addInterceptor(loginFilter).addPathPatterns("/jugerepeat1");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectHost");
        registry.addInterceptor(loginFilter).addPathPatterns("/hostAddController");
        registry.addInterceptor(loginFilter).addPathPatterns("/updateHostPage");
        registry.addInterceptor(loginFilter).addPathPatterns("/updateHostController");
        registry.addInterceptor(loginFilter).addPathPatterns("/right");
        registry.addInterceptor(loginFilter).addPathPatterns("/roleManagement");
        registry.addInterceptor(loginFilter).addPathPatterns("/record");
        registry.addInterceptor(loginFilter).addPathPatterns("/admin_index");
        registry.addInterceptor(loginFilter).addPathPatterns("/adminAdd");
        registry.addInterceptor(loginFilter).addPathPatterns("/host");
        registry.addInterceptor(loginFilter).addPathPatterns("/hostAdd");
        registry.addInterceptor(loginFilter).addPathPatterns("/notice");
        registry.addInterceptor(loginFilter).addPathPatterns("/noticeAdd");
        registry.addInterceptor(loginFilter).addPathPatterns("/repair");
        registry.addInterceptor(loginFilter).addPathPatterns("/repairAdd");
        registry.addInterceptor(loginFilter).addPathPatterns("/user");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorAll");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorAdd");
        registry.addInterceptor(loginFilter).addPathPatterns("/pictureList");
        registry.addInterceptor(loginFilter).addPathPatterns("/opinion");
        registry.addInterceptor(loginFilter).addPathPatterns("/opinionAll");
        registry.addInterceptor(loginFilter).addPathPatterns("/adminUpdate");
        registry.addInterceptor(loginFilter).addPathPatterns("/addrole");
        registry.addInterceptor(loginFilter).addPathPatterns("/insertnotice");
        registry.addInterceptor(loginFilter).addPathPatterns("/findadmin");
        registry.addInterceptor(loginFilter).addPathPatterns("/deletenotice");
        registry.addInterceptor(loginFilter).addPathPatterns("/flushnotice");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectnoticeId");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectOpinionAll");
        registry.addInterceptor(loginFilter).addPathPatterns("/alreadyread");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectopinionalls");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectOpinionAll1");
        registry.addInterceptor(loginFilter).addPathPatterns("/alreadydeleteopinion");
        registry.addInterceptor(loginFilter).addPathPatterns("/uploadPicture");
        registry.addInterceptor(loginFilter).addPathPatterns("/deletePicture");
        registry.addInterceptor(loginFilter).addPathPatterns("/flushPicture");
        registry.addInterceptor(loginFilter).addPathPatterns("/addPicture");
        registry.addInterceptor(loginFilter).addPathPatterns("/recordList");
        registry.addInterceptor(loginFilter).addPathPatterns("/recordListByUser");
        registry.addInterceptor(loginFilter).addPathPatterns("/recordListByDate");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectRepair");
        registry.addInterceptor(loginFilter).addPathPatterns("/repairAddController");
        registry.addInterceptor(loginFilter).addPathPatterns("/deleteOrUpdateRepairController");
        registry.addInterceptor(loginFilter).addPathPatterns("/updateRepairController");
        registry.addInterceptor(loginFilter).addPathPatterns("/deleteRepairController");
        registry.addInterceptor(loginFilter).addPathPatterns("/selectuser");
        registry.addInterceptor(loginFilter).addPathPatterns("/selecthost");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListAble");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorList");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListByVisitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListAllByVisitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListByUser");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListAllByUser");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorListAllByDate");
        registry.addInterceptor(loginFilter).addPathPatterns("/addVisitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/confirmVisitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/deleteVisitor");
        registry.addInterceptor(loginFilter).addPathPatterns("/visitorflush");
//        registry.addInterceptor(loginFilter).addPathPatterns("/wxLogin");
//        registry.addInterceptor(loginFilter).addPathPatterns("/WxRepairs");
//        registry.addInterceptor(loginFilter).addPathPatterns("/WxNotice");
//        registry.addInterceptor(loginFilter).addPathPatterns("/Wxregister");
//        registry.addInterceptor(loginFilter).addPathPatterns("/WxRepairs");
    }
}
